<template>
    <div id="dr2">
        <Breadcrumb style="margin-bottom: 10px">
            <BreadcrumbItem to="/superAdmin">首页</BreadcrumbItem>
            <BreadcrumbItem>运营分析平台</BreadcrumbItem>
            <BreadcrumbItem>当日活跃用户分析</BreadcrumbItem>
        </Breadcrumb>
        <Table style="margin-top: 10px" :maxWidth="1000" :minWidth="10" stripe :columns="columns" :data="data"
               v-if="data&&data.length>0"></Table>

        <div id="loading" v-if="loading">
            <div class="spinner">
                <div class="double-bounce1"></div>
                <div class="double-bounce2"></div>
            </div>
        </div>

    </div>
</template>
<script type="text/ecmascript-6">
    import sessionUtils from '../../model/sessionUtils';
    import ipServer from '../../model/ip';
    import Axios from 'axios';
    export default{
        data(){
            return {
                loading: false,
                pageTotal: 0,
                curPage: 0,
                startTime: null,
                columns: [
                    {
                        title: '日期',
                        key: 'createTime'
                    }, {
                        title: '活跃用户总数',
                        key: 'dayActiveUserTotal'
                    },
                    {
                        title: '司机',
                        key: 'driver'
                    },
                    {
                        title: '流动补胎',
                        key: 'tyreRepair',
                    },
                    {
                        title: '修理',
                        key: 'repair',
                    },
                    {
                        title: '审车',
                        key: 'vehicleInspection',
                    },
                    {
                        title: '加油',
                        key: 'putOil',
                    },
                    {
                        title: '吊车',
                        key: 'hoist'
                    }
                ],
                data: []
            }
        },
        mounted(){
            this.getData();
        },
        methods: {
            typeChange(){
                this.getData();
            },
            pageChange(page){
                this.getData(page);
            },
            search(){
                this.getData();
            },
            getData(page){
                var param = new URLSearchParams();
                param.append('mobile', sessionUtils.getSession("mobile"));
                param.append('token', sessionUtils.getSession("token"));
                if (page) {
                    param.append('pageId', page + "");
                }

                if (this.startTime) {
                    param.append('yearMonthDay', sessionUtils.DateToTime(this.startTime) + "");
                }
                this.loading = true;
                Axios.post(ipServer + "system/selectTempDayActiveUser", param)
                        .then(res => {

                            if (res.data.code == 0) {
                                sessionUtils.setSession("token", res.data.token);
                                         this.data.push(res.data.data);
                                 if (this.data.length == 0)
                                 this.$Message.info("查询数据不存在!");
                            } else if (res.data.code == 3) {
                                sessionUtils.clear();
                                this.$router.push("/login");
                                this.$Message.info(res.data.msg);
                            } else {
                                this.$Message.info(res.data.msg);
                            }
                            this.loading = false;
                        })
                        .catch(err=> {
                            this.loading = false;
                            this.$Message.info(err);
                        });
            }
        }
    }
</script>


<style scoped>
    @import "../../assets/css/loading.css";

</style>